//
//  CSWPopmenu.m
//  网易彩票
//
//  Created by MAC on 16/6/5.
//  Copyright © 2016年 MAC. All rights reserved.
//

#import "CSWPopMenu.h"

@implementation CSWPopMenu

- (IBAction)btnclick:(UIButton *)sender {
    
    if([self.delegate respondsToSelector:@selector(popMenuDidClickClose:)]){
        [self.delegate popMenuDidClickClose:self];
    }
    
}

+ (instancetype)showInPoint:(CGPoint)point{
    
    CSWPopMenu *menu = [[[NSBundle mainBundle] loadNibNamed:@"CSWPopMenu" owner:nil options:nil]lastObject];
    menu.center = point;
    
    [[UIApplication sharedApplication].keyWindow addSubview:menu];
    
    return menu;
}


- (void)hideInPoint:(CGPoint)point complete:(void (^ __nullable)())completion{
    // pop菜单(平移+缩放)
    [UIView animateWithDuration:1 animations:^{
        
        self.center = point;
        
        // 形变
        self.transform = CGAffineTransformMakeScale(0.01, 0.01);
        
    } completion:^(BOOL finished) {
        // 移除
        [self removeFromSuperview];
        completion();
    }];
}

@end
